<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>P60D4d2</title>
</head>

<body>
	<script>
	var arr=new Array('a','b','d','d','c','d','d');
var numarr = new Array();
var indexnum=0,num;
for (var i=0;i<arr.length;i++) {
    num = arr.indexOf('d',0); 
    if(num!=-1){    
        numarr[indexnum]=num;
        indexnum++;
    }
    arr[num]='c';
}
console.log('元素d出现的次数'+indexnum+'<br />');
console.log('所有索引下标:')
for(var i=0;i<numarr.length;i++){
    console.log(numarr[i]+',');
}
	</script>
</body>
</html>
